package per.zzzfwd.douban.crawler;

import org.jsoup.nodes.Element;

import java.util.function.Function;

public class Extractor {

    public String extract(Element element, Function<Element, String> action) {
        if (element == null) {
//            throw new ExtractException("element为空，无法提取数据");
            return null;
        }
        return action.apply(element);
    }

    public String extractUrl(Element element) {
        return element != null && element.hasAttr("href") ? element.attr("href") : null;
    }
}
